/**
 *
 * @author DnD Binary Source
 */
package binarysource;

import org.jdesktop.application.Action;
import javax.swing.JDialog;
import javax.swing.JFrame;

/**
 * The application's main frame.
 */
public class StartScreen extends javax.swing.JFrame {

    /** Creates new form StartScreen */
    public StartScreen() {
        initComponents();
        initInstance();
    }

    private void initInstance(){
        startScreen = this;
    }
    
    public static StartScreen getInstance(){
        if(startScreen == null){
            startScreen = new StartScreen();
        }
        return startScreen;
    }
    
    // Action method used by the Buttons to show the About Box:
    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = BinarySource.getApplication().getMainFrame();
            aboutBox = new AboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        // Showing the About Box screen:
        BinarySource.getApplication().show(aboutBox);
    }
    
        // Action method used by the Buttons to show the Credits Box:
    @Action
    public void showCreditsBox() {
        if (creditsBox == null) {
            JFrame mainFrame = BinarySource.getApplication().getMainFrame();
            creditsBox = new AboutBox(mainFrame);
            creditsBox.setLocationRelativeTo(mainFrame);
        }
        // Showing the About Box screen:
        BinarySource.getApplication().show(creditsBox);
    }
    
        // Action method used by the Buttons to show the Versions Box:
    @Action
    public void showVersionsBox() {
        if (versionsBox == null) {
            JFrame mainFrame = BinarySource.getApplication().getMainFrame();
            versionsBox = new AboutBox(mainFrame);
            versionsBox.setLocationRelativeTo(BinarySource.getApplication().getMainFrame());
        }
        // Showing the Credits Box screen:
        BinarySource.getApplication().show(versionsBox);
    }
    
    // Action method used by the Buttons to show the Character Builder:
    @Action
    public void showCharacterBuilder() {
        if (characterBuilder == null) {
            characterBuilder = new CharacterBuilder();
            characterBuilder.setLocationRelativeTo(BinarySource.getApplication().getMainFrame());
        }
        // Showing the Character Builder screen:
        BinarySource.getApplication().show(characterBuilder);
    }
    
    // Action method used by the Buttons to show the Homebrew Editor:
    @Action
    public void showHomebrewEditor() {
        if (homebrewEditor == null) {
            homebrewEditor = new HomebrewEditor();
            homebrewEditor.setLocationRelativeTo(BinarySource.getApplication().getMainFrame());
        }
        // Showing the Homebrew Editor screen:
        BinarySource.getApplication().show(homebrewEditor);
    }
    
    // Action method used by the JButtons:
    @Action
    public void exit() {
        // Closing the application:
        System.exit(0);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panMain = new javax.swing.JPanel();
        btnRoller = new javax.swing.JButton();
        btnGenerator = new javax.swing.JButton();
        logo = new javax.swing.JLabel();
        btnBuilder = new javax.swing.JButton();
        btnEditor = new javax.swing.JButton();
        btnExit = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        builderMenuItem = new javax.swing.JMenuItem();
        editorMenuItem = new javax.swing.JMenuItem();
        sepFileMenu = new javax.swing.JPopupMenu.Separator();
        builderMenuItem1 = new javax.swing.JMenuItem();
        editorMenuItem1 = new javax.swing.JMenuItem();
        sepFileMenu2 = new javax.swing.JPopupMenu.Separator();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenuItem creditsMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenuItem versionsMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("DnD Binary Source");
        setBackground(new java.awt.Color(0, 0, 0));
        setName("start"); // NOI18N
        setResizable(false);

        panMain.setBackground(new java.awt.Color(0, 0, 0));
        panMain.setName("panMain"); // NOI18N

        btnRoller.setMnemonic('D');
        btnRoller.setText("Dice Roller");
        btnRoller.setToolTipText("Open the Dice Roller");
        btnRoller.setName("btnRoller"); // NOI18N

        btnGenerator.setMnemonic('N');
        btnGenerator.setText("Name Generator");
        btnGenerator.setToolTipText("Open the Name Generator");
        btnGenerator.setName("btnGenerator"); // NOI18N

        logo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/binarysource/resources/logo.png"))); // NOI18N
        logo.setName("logo"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance().getContext().getActionMap(StartScreen.class, this);
        btnBuilder.setAction(actionMap.get("showCharacterBuilder")); // NOI18N
        btnBuilder.setText("Character Builder");
        btnBuilder.setToolTipText("Open the Character Builder");
        btnBuilder.setName("btnBuilder"); // NOI18N

        btnEditor.setAction(actionMap.get("showHomebrewEditor")); // NOI18N
        btnEditor.setText("Homebrew Editor");
        btnEditor.setToolTipText("Open the Homebrew Editor");
        btnEditor.setName("btnEditor"); // NOI18N

        btnExit.setAction(actionMap.get("exit")); // NOI18N
        btnExit.setText("Exit");
        btnExit.setToolTipText("Exit the application");
        btnExit.setName("btnExit"); // NOI18N

        javax.swing.GroupLayout panMainLayout = new javax.swing.GroupLayout(panMain);
        panMain.setLayout(panMainLayout);
        panMainLayout.setHorizontalGroup(
            panMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panMainLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panMainLayout.createSequentialGroup()
                        .addGroup(panMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(btnGenerator, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnRoller, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 157, Short.MAX_VALUE)
                        .addComponent(btnExit, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(logo)
                    .addGroup(panMainLayout.createSequentialGroup()
                        .addComponent(btnBuilder, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 75, Short.MAX_VALUE)
                        .addComponent(btnEditor, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(20, 20, 20))
        );
        panMainLayout.setVerticalGroup(
            panMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panMainLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(logo)
                .addGap(27, 27, 27)
                .addGroup(panMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnBuilder, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnEditor, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE)
                .addComponent(btnRoller)
                .addGap(18, 18, 18)
                .addGroup(panMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnGenerator)
                    .addComponent(btnExit))
                .addContainerGap())
        );

        menuBar.setBackground(new java.awt.Color(255, 255, 255));
        menuBar.setToolTipText("DnD Binary Source");
        menuBar.setFocusable(false);
        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText("File");
        fileMenu.setName("fileMenu"); // NOI18N

        builderMenuItem.setAction(actionMap.get("showCharacterBuilder")); // NOI18N
        builderMenuItem.setText("Character Builder");
        builderMenuItem.setToolTipText("Open the Character Builder");
        builderMenuItem.setName("builderMenuItem"); // NOI18N
        fileMenu.add(builderMenuItem);

        editorMenuItem.setAction(actionMap.get("showHomebrewEditor")); // NOI18N
        editorMenuItem.setText("Homebrew Editor");
        editorMenuItem.setToolTipText("Open the Homebrew Editor");
        editorMenuItem.setName("editorMenuItem"); // NOI18N
        fileMenu.add(editorMenuItem);

        sepFileMenu.setName("sepFileMenu"); // NOI18N
        fileMenu.add(sepFileMenu);

        builderMenuItem1.setMnemonic('D');
        builderMenuItem1.setText("Dice Roller");
        builderMenuItem1.setToolTipText("Open the Dice Roller");
        builderMenuItem1.setName("builderMenuItem1"); // NOI18N
        fileMenu.add(builderMenuItem1);

        editorMenuItem1.setMnemonic('N');
        editorMenuItem1.setText("Name Generator");
        editorMenuItem1.setToolTipText("Open the Name Generator");
        editorMenuItem1.setName("editorMenuItem1"); // NOI18N
        fileMenu.add(editorMenuItem1);

        sepFileMenu2.setName("sepFileMenu2"); // NOI18N
        fileMenu.add(sepFileMenu2);

        exitMenuItem.setAction(actionMap.get("exit")); // NOI18N
        exitMenuItem.setText("Exit");
        exitMenuItem.setToolTipText("Exit the application");
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText("Help");
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        creditsMenuItem.setAction(actionMap.get("showCreditsBox")); // NOI18N
        creditsMenuItem.setName("creditsMenuItem"); // NOI18N
        helpMenu.add(creditsMenuItem);

        versionsMenuItem.setAction(actionMap.get("showVersionsBox")); // NOI18N
        versionsMenuItem.setName("versionsMenuItem"); // NOI18N
        helpMenu.add(versionsMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panMain, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panMain, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new StartScreen().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuilder;
    private javax.swing.JButton btnEditor;
    private javax.swing.JButton btnExit;
    private javax.swing.JButton btnGenerator;
    private javax.swing.JButton btnRoller;
    private javax.swing.JMenuItem builderMenuItem;
    private javax.swing.JMenuItem builderMenuItem1;
    private javax.swing.JMenuItem editorMenuItem;
    private javax.swing.JMenuItem editorMenuItem1;
    private javax.swing.JLabel logo;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JPanel panMain;
    private javax.swing.JPopupMenu.Separator sepFileMenu;
    private javax.swing.JPopupMenu.Separator sepFileMenu2;
    // End of variables declaration//GEN-END:variables
    private JDialog aboutBox;
    private JDialog creditsBox;
    private JDialog versionsBox;
    private JFrame characterBuilder;
    private JFrame homebrewEditor;
    private static StartScreen startScreen;
}
